package com.ict.web.controller.yzq;

import com.ict.common.annotation.Log;
import com.ict.common.core.controller.BaseController;
import com.ict.common.core.domain.AjaxResult;
import com.ict.common.core.page.TableDataInfo;
import com.ict.common.enums.BusinessType;
import com.ict.common.utils.poi.ExcelUtil;
import com.ict.web.domain.PreliminaryInformation;
import com.ict.web.dto.PreliminaryInformationAddDto;
import com.ict.web.service.IPreliminaryInformationService;
import com.ict.web.vo.PreliminaryInformationVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 初验信息--刘杰Controller
 *
 * @author ruoyi
 * @date 2022-03-01
 */
@Api(tags = "初验信息")
@RestController
@RequestMapping("/preliminary/information")
public class PreliminaryInformationController extends BaseController
{
    @Autowired
    private IPreliminaryInformationService preliminaryInformationService;

    /**
     * 查询初验信息--刘杰列表
     */
//    @PreAuthorize("@ss.hasPermi('web:information:list')")
    @ApiOperation("查询初验信息")
    @GetMapping("/list")
    public TableDataInfo list(PreliminaryInformation preliminaryInformation)
    {
        startPage();
        List<PreliminaryInformation> list = preliminaryInformationService.selectPreliminaryInformationList(preliminaryInformation);
        return getDataTable(list);
    }

    /**
     * 导出初验信息--刘杰列表
     */
//    @PreAuthorize("@ss.hasPermi('web:information:export')")
    @ApiOperation("导出初验信息")
    @Log(title = "初验信息--刘杰", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, PreliminaryInformation preliminaryInformation)
    {
        List<PreliminaryInformation> list = preliminaryInformationService.selectPreliminaryInformationList(preliminaryInformation);
        ExcelUtil<PreliminaryInformation> util = new ExcelUtil<PreliminaryInformation>(PreliminaryInformation.class);
        util.exportExcel(response, list, "初验信息--刘杰数据");
    }

    /**
     * 获取初验信息--刘杰详细信息
     */
//    @PreAuthorize("@ss.hasPermi('web:information:query')")
    @ApiOperation("获取初验信息")
    @GetMapping(value = "/{firstCheckId}")
    public PreliminaryInformationVo getInfo(@PathVariable("firstCheckId") Long firstCheckId)
    {
        return preliminaryInformationService.selectPreliminaryInformationByFirstCheckId(firstCheckId);
    }

    /**
     * 新增初验信息--刘杰
     */
//    @PreAuthorize("@ss.hasPermi('web:information:add')")
    @ApiOperation("新增初验信息")
    @Log(title = "初验信息--刘杰", businessType = BusinessType.INSERT)
    @PostMapping
    public Long add(@RequestBody PreliminaryInformationAddDto dto)
    {
        return preliminaryInformationService.insertPreliminaryInformation(dto);
    }

    /**
     * 修改初验信息--刘杰
     */
//    @PreAuthorize("@ss.hasPermi('web:information:edit')")
    @ApiOperation("修改初验信息")
    @Log(title = "初验信息--刘杰", businessType = BusinessType.UPDATE)
    @PutMapping("/edit/{firstCheckId}")
    public AjaxResult edit(@RequestBody PreliminaryInformationAddDto dto,@PathVariable Long firstCheckId)
    {
        return toAjax(preliminaryInformationService.updatePreliminaryInformation(dto,firstCheckId));
    }

    /**
     * 删除初验信息--刘杰
     */
//    @PreAuthorize("@ss.hasPermi('web:information:remove')")
    @ApiOperation("删除初验信息")
    @Log(title = "初验信息--刘杰", businessType = BusinessType.DELETE)
	@DeleteMapping("/{firstCheckId}")
    public AjaxResult remove(@PathVariable Long firstCheckId)
    {
        return toAjax(preliminaryInformationService.deletePreliminaryInformationByFirstCheckId(firstCheckId));
    }
}
